package com.xxtx.trade.jwt;

import java.io.Serializable;

public class JWTInfo implements Serializable, IJWTInfo {
    private String userName;
    private String userId;

    private boolean isExpire = false; //未失效

    public JWTInfo(String userName, String userId) {
        this.userName = userName;
        this.userId = userId;
    }

    public JWTInfo(boolean isExpire  ) {
        this.isExpire = isExpire;
    }

    @Override
    public boolean isExpire() {
        return isExpire;
    }

    public void setExpire(boolean expire) {
        isExpire = expire;
    }

    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserId() {
        return this.userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (o != null && this.getClass() == o.getClass()) {
            JWTInfo jwtInfo = (JWTInfo)o;
            if (this.userName != null) {
                if (this.userName.equals(jwtInfo.userName)) {
                    return this.userId != null ? this.userId.equals(jwtInfo.userId) : jwtInfo.userId == null;
                }
            } else if (jwtInfo.userName == null) {
                return this.userId != null ? this.userId.equals(jwtInfo.userId) : jwtInfo.userId == null;
            }

            return false;
        } else {
            return false;
        }
    }

    public int hashCode() {
        int result = this.userName != null ? this.userName.hashCode() : 0;
        result = 31 * result + (this.userId != null ? this.userId.hashCode() : 0);
        return result;
    }
}
